Use and print note for key only if there are credentials
authorChristian Dywan <christian@twotoasts.de>
Fri, 8 Oct 2010 14:01:07 +0000 (16:01 +0200)
committerChristian Dywan <christian@twotoasts.de>
Fri, 8 Oct 2010 14:03:49 +0000 (16:03 +0200)
Otherwise key might be printed uninitialized.

modules/printbackends/cups/gtkprintbackendcups.c

index 62deac4bcb3593989e39378e258a556f56e6f5d3..7b0b0e2a7271625b2d0dd418c7fcea97ea3eeda3 100644 (file)
@@ -707,7 +707,6 @@ gtk_print_backend_cups_set_password (GtkPrintBackend  *backend,
   GtkPrintBackendCups *cups_backend = GTK_PRINT_BACKEND_CUPS (backend);
   GList *l;
   char   dispatch_hostname[HTTP_MAX_URI];
-  gchar *key;
   gchar *username = NULL;
   gchar *hostname = NULL;
   gchar *password = NULL;
@@ -729,15 +728,15 @@ gtk_print_backend_cups_set_password (GtkPrintBackend  *backend,
 
   if (hostname != NULL && username != NULL && password != NULL)
     {
-      key = g_strconcat (username, "@", hostname, NULL);
+      gchar *key = g_strconcat (username, "@", hostname, NULL);
       g_hash_table_insert (cups_backend->auth, key, g_strdup (password));
+      GTK_NOTE (PRINTING,
+                g_print ("CUPS backend: storing password for %s\n", key));
     }
 
   g_free (cups_backend->username);
   cups_backend->username = g_strdup (username);
 
-  GTK_NOTE (PRINTING,
-            g_print ("CUPS backend: storing password for %s\n", key));
 
   for (l = cups_backend->requests; l; l = l->next)
     {